﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="RecipeList.aspx.vb" Inherits="WSCC_GlutenfreeKent.RecipeList" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <p>
        &nbsp
        <asp:Menu ID="Menu1" runat="server">
        <Items>
            <asp:MenuItem NavigateUrl="~/RecipePages/AddRecipe.aspx" Text="Add a Recipe" 
                Value="Add a Recipe"></asp:MenuItem>
        </Items>
    </asp:Menu>
        <br />
        <asp:Repeater ID="rp_RecipeTags" runat="server" DataSourceID="RecipeTagsDS">
        <ItemTemplate>
        <a href="RecipeList.aspx?Tag=<%# Eval("Tag")%>">
        <%# Eval("Tag")%>&nbsp
        </a>
        </ItemTemplate>
        </asp:Repeater>
        <br />
        <asp:SqlDataSource ID="RecipeTagsDS" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionStringRestaurants %>" 
            ProviderName="<%$ ConnectionStrings:ConnectionStringRestaurants.ProviderName %>" 
            SelectCommand="SELECT [Tag] FROM [TagsRecipes]">           
        </asp:SqlDataSource>
        
    </p>
    <p>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            DataSourceID="RecipeListDS" Height="80px" Width="917px">
            <Columns>
                <asp:ImageField DataImageUrlField="Photo" HeaderText="Photo">
                    <ControlStyle Height="200px" Width="200px" />
                </asp:ImageField>
                <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
                <asp:BoundField DataField="UserName" HeaderText="UserName" 
                    SortExpression="UserName" />
                <asp:HyperLinkField DataNavigateUrlFields="ID" 
                    DataNavigateUrlFormatString="RecipeDetails.aspx?ID={0}" 
                    HeaderText="Full Recipe" Text="Click here..." />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="RecipeListDS" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionStringRestaurants %>" 
            ProviderName="<%$ ConnectionStrings:ConnectionStringRestaurants.ProviderName %>" 
            CancelSelectOnNullParameter="false">
             <SelectParameters>
                <asp:QueryStringParameter Name="Tag" QueryStringField="Tag" Type="String" />
           
            </SelectParameters>
        </asp:SqlDataSource>
        <br />
        <asp:ListView ID="ListView1" runat="server" DataKeyNames="ID" 
            DataSourceID="RecipeListViewDS" GroupItemCount="3" EnableTheming="True" style="margin-right: 116px" >
            <AlternatingItemTemplate>
                <td runat="server" style="background-color: #FFFFCC; color: Olive; width: 300px;">
                    <a href='RecipeDetails.aspx?ID=<%# Eval("ID")  %>' >
                    <asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' />
                    </a>
                    <br />
                    <a href='RecipeDetails.aspx?ID=<%# Eval("ID")  %>' >
                    <img alt="" src='<%# Eval("Photo") %>' />
                    </a>
                    <br />
                    <a href='../Account/Profile.aspx?UserName=<%# Eval("Username") %>' >
                    <asp:Label ID="Label99" runat="server" Text='<%# Eval("UserName") %>' />
                    </a>
                </td>
            </AlternatingItemTemplate>
            <EditItemTemplate>
                <td runat="server" style="background-color: #FFCC66;color: #000080;">
                    ID:
                    <asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("ID") %>' />
                    <br />Title:
                    <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Title") %>' />
                    <br />FullRecipe:
                    <asp:TextBox ID="FullRecipeTextBox" runat="server" 
                        Text='<%# Bind("FullRecipe") %>' />
                    <br />Photo:
                    <asp:TextBox ID="PhotoTextBox" runat="server" Text='<%# Bind("Photo") %>' />
                    <br />UserName:
                    <asp:TextBox ID="UserNameTextBox" runat="server" 
                        Text='<%# Bind("UserName") %>' />
                    <br />
                    <asp:Button ID="UpdateButton" runat="server" CommandName="Update" 
                        Text="Update" />
                    <br />
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                        Text="Cancel" />
                    <br />
                </td>
            </EditItemTemplate>
            <EmptyDataTemplate>
                <table runat="server" 
                    style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
                    <tr>
                        <td>
                            No data was returned.</td>
                    </tr>
                </table>
            </EmptyDataTemplate>
            <EmptyItemTemplate>
<td runat="server" />
            </EmptyItemTemplate>
            <GroupTemplate>
                <tr ID="itemPlaceholderContainer" runat="server">
                    <td ID="itemPlaceholder" runat="server">
                    </td>
                </tr>
            </GroupTemplate>
            <InsertItemTemplate>
                <td runat="server" style="">
                    Title:
                    <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Title") %>' />
                    <br />FullRecipe:
                    <asp:TextBox ID="FullRecipeTextBox" runat="server" 
                        Text='<%# Bind("FullRecipe") %>' />
                    <br />Photo:
                    <asp:TextBox ID="PhotoTextBox" runat="server" Text='<%# Bind("Photo") %>' />
                    <br />UserName:
                    <asp:TextBox ID="UserNameTextBox" runat="server" 
                        Text='<%# Bind("UserName") %>' />
                    <br />
                    <asp:Button ID="InsertButton" runat="server" CommandName="Insert" 
                        Text="Insert" />
                    <br />
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                        Text="Clear" />
                    <br />
                </td>
            </InsertItemTemplate>
            <ItemTemplate>
               <td id="Td1" runat="server" style="background-color: #FFFFCC; color: Olive;">
                    <a href='RecipeDetails.aspx?ID=<%# Eval("ID")  %>' >
                    <asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' />
                    </a>
                    <br />
                    <a href='RecipeDetails.aspx?ID=<%# Eval("ID")  %>' >
                    <img alt="" src='<%# Eval("Photo") %>' />
                    </a>
                    <br />
                    <a href='../Account/Profile.aspx?UserName=<%# Eval("Username") %>' >
                    <asp:Label ID="Label99" runat="server" Text='<%# Eval("UserName") %>' />
                    </a>
                </td>
            </ItemTemplate>
            <LayoutTemplate>
                <table runat="server">
                    <tr runat="server">
                        <td runat="server">
                            <table ID="groupPlaceholderContainer" runat="server" border="1" 
                                style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
                                <tr ID="groupPlaceholder" runat="server">
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr runat="server">
                        <td runat="server" 
                            style="text-align: center;background-color: #FFCC66;font-family: Verdana, Arial, Helvetica, sans-serif;color: #333333;">
                            <asp:DataPager ID="DataPager1" runat="server" PageSize="21" >
                                <Fields>
                                    <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                                        ShowLastPageButton="True" />
                                </Fields>
                            </asp:DataPager>
                        </td>
                    </tr>
                </table>
            </LayoutTemplate>
            <SelectedItemTemplate>
                <td runat="server" 
                    style="background-color: #FFCC66;font-weight: bold;color: #000080;">
                    ID:
                    <asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
                    <br />Title:
                    <asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' />
                    <br />FullRecipe:
                    <asp:Label ID="FullRecipeLabel" runat="server" 
                        Text='<%# Eval("FullRecipe") %>' />
                    <br />Photo:
                    <asp:Label ID="PhotoLabel" runat="server" Text='<%# Eval("Photo") %>' />
                    <br />
                    <asp:Label ID="UserNameLabel" runat="server" Text='<%# Eval("UserName") %>' />
                    <br />
                </td>
            </SelectedItemTemplate>
        </asp:ListView>
        <asp:SqlDataSource ID="RecipeListViewDS" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionStringRestaurants %>" 
            ProviderName="<%$ ConnectionStrings:ConnectionStringRestaurants.ProviderName %>" 
            SelectCommand="SELECT * FROM [Recipes] ORDER BY [ID] DESC">
        </asp:SqlDataSource>
        <br />
    </p>
</asp:Content>
